package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.Result;
import com.atguigu.eduservice.entity.excel.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author test.java
 * @since 2023-03-16
 */
@RestController
@RequestMapping("/eduservice/edu-subject")
public class EduSubjectController {

	//读取前端上传的excel文件->保存到数据库

	@Resource
	private EduSubjectService eduSubjectService;

	//添加课程分类
	@ApiOperation(value = "Excel批量导入")
	@PostMapping("addSubject")
	public Result uploadExcel(@RequestBody MultipartFile multipartFile){

		eduSubjectService.saveExcels(multipartFile,eduSubjectService);
        return Result.ok();
	}

	@ApiOperation(value = "嵌套数据列表")
	@GetMapping("/getAllSubjects")
	public Result nestedList(){

		List<OneSubject> subjectNestedVoList = eduSubjectService.getAllOneAndTwo();
		return Result.ok().data("list", subjectNestedVoList);
	}
}

